<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
<script type="text/javascript" src="../static/easyui/jquery.min.js"></script>
<script type="text/javascript" src="../static/easyui/jquery.easyui.min.js"></script>
<script type="text/javascript" src="../static/easyui/locale/easyui-lang-zh_CN.js"></script>
<link rel="stylesheet" href="../static/easyui/themes/icon.css">
<link rel="stylesheet" href="../static/easyui/themes/metro-orange/easyui.css">
<link rel="stylesheet" href="../static/easyui/themes/metro-red/window.css">
</head>
<body>
<script type="text/javascript">
$('#tt').tabs({
    border:false,
    onSelect:function(title){
		alert(title+' is selected');
    }
});


function tables(tkds){
	//初始化表格
	$('#shunzheti').datagrid({
	    url:'tikudanshunchaxun',
	    queryParams:{
	    	tmsub:tkds
 		},
	    columns:[[
			{field:'TMZID',width:1,checkbox:true,title:'班次编号',align:'center'},
			{field:'tm',width:1,title:'题目',width:320,align:'center'},
			{field:'TMFS',width:1,title:'分数',width:320,align:'center'}
	    ]],
	    pagination:true,
	    pageNumber:1,
	    pageSize:5,
	    pageList:[5,10,15]
	});
}	

$(function(){
	 tables(null);
	 
		$(".pxkjpf_xianshi").click(function(){
			tables();
		})
	 	
})
function table(tkzh){
	$('#zongheti').datagrid({
	    url:'tikuzonghechaxun',
	    queryParams:{
	    	tmsub:tkzh
 		},
	    columns:[[
			{field:'TMZID',width:1,checkbox:true,title:'班次编号',align:'center'},
			{field:'tm',width:1,title:'题目',width:320,align:'center'},
			{field:'TMFS',width:1,title:'分数',width:320,align:'center'}
	    ]],
	    pagination:true,
	    pageNumber:1,
	    pageSize:5,
	    pageList:[5,10,15]
	});
	
}
$(function(){
	//选择题和综合题获取分数并累加
   var timuzongfen=0;
	 //选择框隐藏
	$("#shunzheti2").hide();
	 //判断框隐藏
	$("#sjxz_panduan").hide();
	 
	$('#shunzheti').datagrid({
	 onSelect:function(index,row){
		 timuzongfen+=row["TMFS"];
		$(".sjxz_zongfenleijia").text(timuzongfen);
		$("#shunzheti2").show();
		
	 },
	 onUnselect:function(index,row){
		 timuzongfen-=row["TMFS"];
		 $(".sjxz_zongfenleijia").text(timuzongfen);
		 $("#shunzheti2").show();
	 }
	})
	
	$('#zongheti').datagrid({
	 onSelect:function(index,row){
		 timuzongfen+=row["TMFS"];
		$(".sjxz_zongfenleijia").text(timuzongfen);
		$("#shunzheti2").show();
		
	 },
	 onUnselect:function(index,row){
		 timuzongfen-=row["TMFS"];
		 $(".sjxz_zongfenleijia").text(timuzongfen);
		 $("#shunzheti2").show();
	 }
	})
	 
	        
	//显示
	 $('#Tiku').combobox({
		 url:'tiku',
		 valueField:'QSBID',
		 textField:'QSBBANK'
	 });
	
	 $('#Zongfen').combobox({
		 url:'zongfen',
		 valueField:'OUTID',
		 textField:'OUTZONF'
	 });
	 
	 
	 $('#Chujuanren').combobox({
		 url:'chujuanren',
		 valueField:'EMPID',
		 textField:'empname'
	 });
	 
	 $('#Shijuan').combobox({
		 url:'shijuan2',
		 valueField:'OUTID',
		 textField:'OUTNAME'
	 });
	
	 table(null);
	 
		$(".pxkjpf_xianshi").click(function(){
			table();
		})
		$(".sjxz_bao").click(function(){
			 var empid = $(".He_text_t").attr("id");
			 var mc=$("#Shijuan").combobox("getText");
			 var tk=$("#Tiku").combobox("getText"); 
			 var zf=$("#Zongfen").combobox("getText");
			 var timufenshu=$("#zongfenleijia").text();
			 $(".sjxz_budengyu").text(zf);
			 if(mc==""){
				 $("#sjxz_panduan").show();
				 $("#sjxz_panduan").text("试卷名称不能为空（勾选/输入）!").fadeOut(3000);
				 return;
			 }else if(tk==""){
				 $("#sjxz_panduan").show();
				 $("#sjxz_panduan").text("题库不能为空（勾选/输入）!").fadeOut(3000);
				 return;
			 }else if(zf==""){
				 $("#sjxz_panduan").show();
				 $("#sjxz_panduan").text("总分不能为空（勾选/输入）!").fadeOut(3000);
				 return;
			 }else if(timufenshu==""){
				 $("#sjxz_panduan").show();
				 $("#sjxz_panduan").text("请先勾选题目！").fadeOut(3000);
				 return;
			 }
			 else if(zf!=timufenshu){
            	return $("#sjxz_zongfentankuang").window("open");
			 }
            //试卷表
			 $.ajax({
					 url:"shijuan",
					 type:"post",
					 data:{
						empid:empid,
						mc:mc,
						zf:zf
					 },
				     success:function(){
				    	 
				     }
		
				 })

				 var rows = $("#shunzheti").datagrid("getChecked");
				 var row = $("#zongheti").datagrid("getChecked");
				 //选择题
				 for (var i = 0; i < rows.length; i++) {
					var tmid = rows[i]["TMZID"];
					$.ajax({
						 url:"tmshijuan",
						 type:"post",
						 data:{
							tmid:tmid
						 },
					     success:function(){
					    	 
					     }
					 })
				 }
				 //综合题
				 for (var i = 0; i < row.length; i++) {
						var tmid = row[i]["TMZID"];
						$.ajax({
							 url:"tmshijuan",
							 type:"post",
							 data:{
								tmid:tmid
							 },
						     success:function(){
						    	 
						     }
						 })
				 }
	    	 $("#sjxz_chenggong").window("open");
	 	 });

		 $(".sjxzqueding").click(function(){
			  $("#sjxz_zongfentankuang").window("close");
		 }) 
		 
		 $(".sjxz_queding").click(function(){
			$("#sjxz_chenggong").window("close"); 
			close("新增试卷");
		});
		 
		 $(".sjxz_qu").click(function(){
			    $("#sjxz_quxiao").window("open");
			});
		 $(".sjxz_queding").click(function(){
				$("#sjxz_quxiao").window("close"); 
				close("新增试卷");
			 
		 })
		 
	})
</script>
                <div class="sjxz_panduan" id="sjxz_panduan" ></div>
                <div id="sjxz_zongfentankuang" class="easyui-window" title="总分" style="width:340px;height:205px"
		    		    data-options="closed:true,minimizable:false,maximizable:false,collapsible:false,modal:true">
		    		             <div class="sjxz_zongfentankuangone">
		    		             	               <div class="sjxz_zongfen1">题目分数与总分不同！<span class="sjxz_zongfenleijia"></span>分≠<span class="sjxz_budengyu"></span>分</div>
		    		             </div> 
		    		             <div class="sjxz_zongfentankuangtwo">
		    		                              <button id="dsx-beok" class="sjxzqueding">确定</button>
		    		             </div>
		    	</div>
		    	<div id="sjxz_chenggong" class="easyui-window" title="新增" style="width:320px;height:165px"
		    		     data-options="closed:true,minimizable:false,maximizable:false,collapsible:false,modal:true">
		    		             <div class="sjxzchenggong_one">
		    		                   <div class="sjxz_chenggong">试卷新增成功！</div>
		    		                  
		    		             </div>
		    		             <div class="sjxzchenggong_two">
		    		                  <button id="dsx-beok" class="sjxz_queding">确定</button>
		    		             </div>
		      </div>
		      <div id="sjxz_quxiao" class="easyui-window" title="新增" style="width:320px;height:165px"
		    		     data-options="closed:true,minimizable:false,maximizable:false,collapsible:false,modal:true">
		    		             <div class="sjxzchenggong_one">
		    		                   <div class="sjxz_chenggong">确认取消新增试卷？</div>
		    		                  
		    		             </div>
		    		             <div class="sjxzchenggong_two">
		    		                  <button id="dsx-beok" class="sjxz_queding">确定</button>
		    		             </div>
		      </div>
	    <div class="shijuanxingzeng_zong">
                <div class="shijuanxingzeng_top">
                         <div class="sjxz_xianshi2">
                             <div class="sjxz_shijuanming">
                     		      <div class="sjxz_shijuanmingtu">
                     		           <img src="../static/tyl/images/shiti.png">
                     		      </div>
				                  <div class="sjxz_shijuanmingzi" id="sjxz_shijuan">试卷名称：
				                  <input id="Shijuan" class="easyui-combobox shijuanshuru">
		    		                </div>
		    		         </div>
		    		         <div class="sjxz_chujuanren">
		    		                <div class="sjxz_chujuanrentu">
                     		           <img src="../static/tyl/images/chujuanren.png">
                     		        </div>
		    		                <div class="sjxz_chujuanrenzi">出卷人:
		    		                 <input  class="chujuanren" value="${hopa.empname }" readonly="readonly">
		    		                </div>
		    		         </div>
				           </div>
                     <div class="sjxz_xianshi">
		    		           <div class="sjxz_zongfen">
                     		      <div class="sjxz_zongfentu">
                     		           <img src="../static/tyl/images/zongfen.png">
                     		      </div>
				                  <div class="sjxz_zongfenzi">试卷总分：
		    		                    <input id="Zongfen" class="easyui-combobox zongfenshuru">
		    		            </div>
		    		         </div>
		    		         <div class="sjxz_tiku">
		    		                  <div class="sjxz_tikutu">
                     		              <img src="../static/tyl/images/tiku.png">
                     		         </div>
		    		                  <div class="sjxz_tikuzi">题库：
		    		                  <input id="Tiku" class="easyui-combobox tikeshuru">
				         
		    		                </div>
				              </div>
				           </div>
		    	  </div>
		 
             <div id="shi-juan" class="shijuanxingzeng_bottom easyui-tabs">
             	<div title="选择题" class="sjxz_left">
                   	<div class="shunzheti">
                   	    <div class="shunzheti2" id="shunzheti2">
                   	        (已选择<span class="sjxz_zongfenleijia" id="zongfenleijia"></span>分)
                   	    </div> 
                   	</div>
                    <div style="margin-left:15px;">
		                   	<table id="shunzheti" class="easyui-datagrid"
			                   style="width:100%;height:240px"
	    	                  data-options="fitColumns:true">
		                    </table>
	                </div>
                </div>
               	<div title="综合题" class="sjxz_right">
                       <div class="zongheti">
                          <div class="shunzheti2" id="shunzheti2">
                                (已选择<span class="sjxz_zongfenleijia"></span>分)
                          </div>
                       <div style="margin-left:15px;">
		                     <table id="zongheti" class="easyui-datagrid"
		                     style="width:100%;height:240px"
	    	                  data-options="fitColumns:true">
		                    </table>
	                   </div>
                     </div>
             </div> 
          </div>
             <div class="shijuanxingzeng_anniu">
                   <div class="sjxz_baocun"><button class="sjxz_bao"><img src="../static/tyl/images/go.png">保存</button></div>
                   <div class="sjxz_quxiao"><button class="sjxz_qu"><img src="../static/tyl/images/cha.png">取消</button></div>
             </div>
       </div>
       
</body>
</html>